<template>
  <!-- <el-radio-group v-model="data.theme" v-for="(item,index) in themeArray" :key="index">
    <el-radio :label="item.value">{{item.name}}</el-radio>
  </el-radio-group>-->
  <div class="theme-list">
    <div
      v-for="(item,index) in themeArray"
      :key="index"
      class="theme-item"
      :class="{'is-active':item.value === data.theme}"
      @click="handlerTheme(item)"
    >
      <span>{{item.name}}</span>
      <div class="is-active-icon" v-if="item.value === data.theme">
        <i class="icon-check"></i>
      </div>
      <el-image style="width: 220px;height: 120px;" :src="item.img" />
    </div>
  </div>
</template>
<script>
import { setTheme } from 'utils/util'
import { defineComponent, reactive, ref, computed } from 'vue'
import { useStore } from 'vuex'
export default defineComponent({
  props: {},
  setup() {
    const store = useStore()
    const data = reactive({
      theme: '',
    })
    const themeArray = ref([
      { name: '默认主题', value: '', img: '' },
      {
        name: '蓝色主题',
        value: 'theme-bule',
        img: '/img/theme/blue-theme.jpg',
      },
      {
        name: '白色主题',
        value: 'theme-white',
        img: '/img/theme/white-theme.jpg',
      },
    ])
    //主题
    data.theme = computed(() => store.getters.themeKey)

    const handlerTheme = (item) => {
      setTheme(item.value)
      store.commit('SET_THEME_KEY', item.value)
      data.theme = item.value
    }
    return {
      data,
      themeArray,
      handlerTheme,
    }
  },
})
</script>